package org.lgiavedoni.android.franq.event.listener;

import org.lgiavedoni.android.franq.core.contact.Contact;
import org.lgiavedoni.android.franq.core.envent.Event;
import org.lgiavedoni.android.franq.core.envent.listener.EventListener;
import org.lgiavedoni.android.franq.event.CallFromEvent;
import org.lgiavedoni.android.franq.service.communication.CommunicationService;
import org.lgiavedoni.android.franq.service.phone.ContactService;

public class CallFromEventListener extends EventListener {

	@Override
	public void exec(Event event) {
		String number = ((CallFromEvent) event).getNumber();
		Contact contact = ContactService.inst.getContactByNumber(number);
		String contactString = contact != null ? contact.getName() : number;

		CommunicationService.inst.sendDefaultTextMessage("RING RING..." + contactString + " is calling");
	}

	@Override
	public Class<CallFromEvent> getClassEvent() {
		return CallFromEvent.class;
	}

}
